.TH std::experimental::ranges::find,std::experimental::ranges::find_if, 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::ranges::find,std::experimental::ranges::find_if, \- std::experimental::ranges::find,std::experimental::ranges::find_if,

.SH Synopsis

   Defined in header <experimental/ranges/algorithm>
   template< InputIterator I, Sentinel<I> S, class T, class Proj =
   ranges::identity >

       requires IndirectRelation<ranges::equal_to<>, projected<I,       \fB(1)\fP (ranges TS)
   Proj>, const T*>

   I find( I first, S last, const T& value, Proj proj = Proj{} );
   template< InputRange R, class T, class Proj = ranges::identity >

       requires IndirectRelation<ranges::equal_to<>,
                                 projected<ranges::iterator_t<R>,       \fB(2)\fP (ranges TS)
   Proj>, const T*>

   ranges::safe_iterator_t<R> find( R&& r, const T& value, Proj proj =
   Proj{} );
   template< InputIterator I, Sentinel<I> S, class Proj =
   ranges::identity,
                                                                        \fB(3)\fP (ranges TS)
             IndirectUnaryPredicate<projected<I, Proj>> Pred >

   I find_if( I first, S last, Pred pred, Proj proj = Proj{} );
   template< InputRange R, class Proj = ranges::identity,

             IndirectUnaryPredicate<projected<ranges::iterator_t<R>,
   Proj>> Pred >                                                        \fB(4)\fP (ranges TS)

   ranges::safe_iterator_t<R> find_if( R&& r, Pred pred, Proj proj =
   Proj{} );
   template< InputIterator I, Sentinel<I> S, class Proj =
   ranges::identity,
                                                                        \fB(5)\fP (ranges TS)
             IndirectUnaryPredicate<projected<I, Proj>> Pred >

   I find_if_not( I first, S last, Pred pred, Proj proj = Proj{} );
   template< InputRange R, class Proj = ranges::identity,

             IndirectUnaryPredicate<projected<ranges::iterator_t<R>,
   Proj>> Pred >                                                        \fB(6)\fP (ranges TS)

   ranges::safe_iterator_t<R> find_if_not( R&& r, Pred pred, Proj proj
   = Proj{} );

   Returns the first element in the range [first, last) that satisfies specific
   criteria:

   1) find searches for an element whose projected value is equal to value (i.e., value
   == ranges::invoke(proj, *i)).
   3) find_if searches for an element for whose projected value predicate p returns
   true (i.e., ranges::invoke(pred, ranges::invoke(proj, *i))) is true).
   5) find_if_not searches for an element for whose projected value predicate q returns
   false (i.e., ranges::invoke(pred, ranges::invoke(proj, *i))) is false).
   2,4,6) Same as (1,3,5), but uses r as the source range, as if using ranges::begin(r)
   as first and ranges::end(r) as last.

   Notwithstanding the declarations depicted above, the actual number and order of
   template parameters for algorithm declarations is unspecified. Thus, if explicit
   template arguments are used when calling an algorithm, the program is probably
   non-portable.

.SH Parameters

   first, last - the range of elements to examine
   r           - the range of elements to examine
   value       - value to compare the projected elements to
   pred        - predicate to apply to the projected elements
   proj        - projection to apply to the elements

.SH Return value

   Iterator to the first element satisfying the condition. If no such element is found,
   returns an iterator that compares equal to last.

.SH Complexity

   At most last - first applications of the predicate and projection.

.SH Possible implementation

.SH First version
   template<InputIterator I, Sentinel<I> S, class T, class Proj = ranges::identity>
       requires IndirectRelation<ranges::equal_to<>, projected<I, Proj>, const T*>
   I find(I first, S last, const T& value, Proj proj = Proj{})
   {
       for (; first != last; ++first)
           if (ranges::invoke(proj, *first) == value)
               break;
       return first;
   }
.SH Second version
   template<InputIterator I, Sentinel<I> S, class Proj = ranges::identity,
            IndirectUnaryPredicate<projected<I, Proj>> Pred>
   I find_if(I first, S last, Pred pred, Proj proj = Proj{})
   {
       for (; first != last; ++first)
           if (ranges::invoke(pred, ranges::invoke(proj, *first)))
               break;
       return first;
   }
                                    Third version
   template<InputIterator I, Sentinel<I> S, class Proj = ranges::identity,
            IndirectUnaryPredicate<projected<I, Proj>> Pred>
   I find_if_not(I first, S last, Pred pred, Proj proj = Proj{})
   {
       for (; first != last; ++first)
           if (!ranges::invoke(pred, ranges::invoke(proj, *first)))
               break;
       return first;
   }

.SH Example

    This section is incomplete
    Reason: no example

.SH See also

   find
   find_if       finds the first element satisfying specific criteria
   find_if_not   \fI(function template)\fP
   \fI(C++11)\fP
                 finds the first two adjacent items that are equal (or satisfy a given
   adjacent_find predicate)
                 \fI(function template)\fP
   find_end      finds the last sequence of elements in a certain range
                 \fI(function template)\fP
   find_first_of searches for any one of a set of elements
                 \fI(function template)\fP
   mismatch      finds the first position where two ranges differ
                 \fI(function template)\fP
   search        searches for a range of elements
                 \fI(function template)\fP

.SH Category:
     * Todo no example
